# # 元组的嵌套
# t1 = ((1, 2, 3), (4, 5, 6))
# print(t1[0][0])

# # 定义3个元素的元组
# t1 = (1, 'Hello', True)
# # 定义1个元素的元组
# t2 = ('Hello',)
# # 注意，必须带有逗号，否则不是元组类型

# # 根据下标(索引)取出数据
# t1 = (1, 2, 'hello')
# print(t1[2])  # 结果：'hello'
#
# # 根据index0)，查找特定元素的第一个匹配项
# t1 = (1, 2, 'hello', 3, 4, 'hello')
# print(t1.index('hello'))  # 结果：2
#
# #  统计某个数据在元组内出现的次数
# t1 = (1, 2, 'hello', 3, 4, 'hello')
# print(t1.count('hello'))  # 结果：2
#
# #  统计元组内的元素个数
# t1 = (1, 2, 3)
# print(len(t1))  # 结果：3

# # 尝试修改元组内容
# t1 = (1, 2, 3)
# t1[0] = 5

# # 修改元组内的list的内容
# t1 = (1, 2, ['bite', 'Python'])
# t1[2][1] = 'best'
# print(t1)

# # 通过下标索引取值
# my_str = "bite is the best"
# value = my_str[2]
# value2 = my_str[-4]
# print(f"从字符串{my_str}取下标为2的元素值为{value},取下标为-4的元素的值为{value2}")
#
# # 结果：从字符串bite is the best取下标为2的元素值为t,取下标为-4的元素的值为b

# my_str = "bite is the best"
# print(my_str.index("is"))
#
# # 结果：5

# my_str = "itheima and itcast"
# new_my_str = my_str.replace("it", "go")
# print(new_my_str)
#
# # 结果：goheima and gocast

# my_str = "bite is the best"
# my_str_list = my_str.split(" ")
# print(my_str_list)
#
# # 结果：['bite', 'is', 'the', 'best']

# my_str = " bite is the best "
# new_my_str = my_str.strip()
# print(new_my_str)
#
# # 结果:bite is the best

# my_str = "12bite is 12the best212"
# new_my_str = my_str.strip("12")
# print(new_my_str)

# my_str = "itheima and itcast"
# count = my_str.count("it")
# print(f"字符串{my_str}中it出现的次数是: {count}")
#
# # 结果：字符串itheima and itcast中it出现的次数是: 2

# # 语法，字典[Key]可以取到对应的value
# stu_score = {"李四": 99, "张三": 88,"王二麻子": 77}
# print(stu_score["李四"])   # 结果：99
# print(stu_score["张三"])   # 结果：88
# print(stu_score["王二麻子"])  # 结果：77

# # 定义重复Key的宇典
# my_dict1 = {"王力鸿": 99, "王力鸿": 88, "林俊节": 77}
# print(f"重复key的字典的内容是:{my_dict1}")
#
# # 结果：重复key的字典的内容是:{'王力鸿':88，林俊节':77}

# stu_score_dict = {
#     "王力鸿": {
#         "语文": 77,
#         "数学": 66,
#         "英语": 33
#     }, "周杰轮": {
#         "语文": 88,
#         "数学": 86,
#         "英语": 55
#     }, "林俊节": {
#         "语文": 99,
#         "数学": 96,
#         "英语": 66
#     }
# }
# print(f"学生的考试信息是:{stu_score_dict}")
#
# score = stu_score_dict["周杰轮"]["语文"]
# print(f"周杰轮的语文分数是:{score}")

# my_dict1 = {"王力鸿": 88, "林俊节": 77}
# my_dict1['王力鸿'] = 66
# print(my_dict1)

# my_dict1 = {"王力鸿": 88, "林俊节": 77}
# value = my_dict1.pop("王力鸿")
# print(value)   # 结果：88
# print(my_dict1)  # 结果：{'林俊节': 77}

# my_dict1 = {"王力鸿": 88, "林俊节": 77}
# my_dict1.clear()
# print(my_dict1)
#
# # 结果：{}

# # 获取全部的key
# my_dict = {"周杰轮": 99, "王力鸿": 88, "林俊节": 77}
# keys = my_dict.keys()
# print(f"字典的全部keys是:{keys}")  # 结果：字典的全部keys是:dict_keys(['周杰轮', '王力鸿', '林俊节'])
#
# # 遍历字典
# # 方式一：通过获取到全部的key来完成遍历
# for key in keys:
#     print(f"字典的key是:{key}")
#     print(f"字典的value是: {my_dict[key]}")
#
# # 方式二：直接对字典进行for循环，每一次循环都是直接得到key
# for key in my_dict:
#     print(f"字典的key是:{key}")
#     print(f"字典的value是: {my_dict[key]}")

# my_set = {"Hello", "World"}
# my_set.add("bite")
# print(my_set)  # 结果：{'World', 'bite', 'Hello'}（顺序可能会变）

# my_set = {"Hello", "World"}
# my_set.remove("World")
# print(my_set)  # 结果：{'Hello'}

# my_set = {"Hello", "World"}
# element = my_set.pop()
# print(my_set)  # 结果：{'Hello'}
# print(element)  # 结果：World

# my_set = {"Hello", "World"}
# my_set.clear()
# print(my_set)  # 结果：set()

# set1 = {1, 2, 3}
# set2 = {1, 5, 6}
# set3 = set1.difference(set2)
# print(set3)  # 结果：{2, 3}
# print(set2)  # 结果：{1, 5, 6}
# print(set1)  # 结果：{1, 2, 3}

# set1 = {1, 2, 3}
# set2 = {1, 5, 6}
# set1.difference_update(set2)
# print(set1)  # 结果：{2, 3}
# print(set2)  # 结果：{1, 5, 6}

set1 = {1, 2, 3}
set2 = {1, 5, 6}
set3 = set1.union(set2)
print(set3)  # 结果：{1, 2, 3, 5, 6}
print(set1)  # 结果：{1, 2, 3}
print(set2)  # 结果：{1, 5, 6}
